<!-- $Id: goods_stats.htm 2015-10-22 14:45:21Z langlibin $ -->

{if $full_page}
{include file="pageheader.htm"}
{insert_scripts files="../js/utils.js,listtable.js"}
<script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script>
<link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />
<div id="tabbar-div">
    <p>
        <span class="tab-front" id="general-tab" onclick="javascript:location.href='goods_stats.php'">{$lang.sell_list}</span>
        <span class="tab-back" id="area-tab" onclick="javascript:location.href='goods_sell_detail.php'">{$lang.sell_detail}</span>
        <span class="tab-back" id="from-tab"  onclick="javascript:location.href='goods_purchase_rate.php'">{$lang.purchase_rate}</span>
    </p>
</div>
<div class="main-div">
    <p style="margin: 10px">{$lang.notice_goods_status}</p>
</div>

<div class="form-div">
    <form action="javascript:searchOrderList(1)" name="searchForm">
        {$lang.add_time}&nbsp;
        <input name="start_date" value="{$start_date}" style="width:100px;height:20px;" onclick="return showCalendar(this, '%Y-%m-%d', false, false, this);" />
        {$lang.to} &nbsp;
        <input name="end_date" value="{$end_date}" style="width:100px;height:20px;" onclick="return showCalendar(this, '%Y-%m-%d', false, false, this);" />
        &nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" name="submit" value="{$lang.query}" class="button" />
        <input type="button" name="export" value="{$lang.batch_export}" class="button" onclick="batch_export()" />
    </form>
</div>

<form method="post" action="" name="listForm" onsubmit="">
    <div class="list-div" id="listDiv">
        {/if}
        <table cellpadding="3" cellspacing="1">
            <tr>
                <th>{$lang.order}</th>
                <th>{$lang.goods_name}</th>
                <th>{$lang.goods_sn}</th>
                <th><a href="javascript:listTable.sort('sales_volume'); ">{$lang.sales_volume}</a>{$sort_sales_volume}</th>
                <th><a href="javascript:listTable.sort('sales_money'); ">{$lang.sales_money}</a>{$sort_sales_money}</th>
                <th><a href="javascript:listTable.sort('average_price'); ">{$lang.average_price}</a>{$sort_average_price}</th>
            </tr>

            {foreach from=$sell_list item=item name=name}
            <tr>
                <td>{$item.no}</td>
                <td>{$item.goods_name}</td>
                <td>{$item.goods_sn}</td>
                <td>{$item.sales_volume}</td>
                <td>{$item.sales_money}</td>
                <td>{$item.average_price}</td>
            </tr>
            {foreachelse}
            <tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
            {/foreach}
        </table>
        <table cellpadding="4" cellspacing="0">
            <tr>
                <td align="right">{include file="page.htm"}</td>
            </tr>
        </table>
        {if $full_page}
</form>

<script type="text/javascript" language="JavaScript">
    listTable.recordCount = {$record_count};
    listTable.pageCount = {$page_count};

    {foreach from=$filter item=item key=key}
    listTable.filter.{$key} = '{$item}';
    {/foreach}

    {literal}

    /* 搜索商品销售排行 */
    function searchOrderList(date_type)
    {
    	if (typeof(date_type) == "undefined")
    	{
    		date_type = 0;
    	}
        listTable.filter.start_date = Utils.trim(document.forms['searchForm'].elements['start_date'].value);
        listTable.filter.end_date = Utils.trim(document.forms['searchForm'].elements['end_date'].value);
        listTable.filter.date_type = date_type;
        listTable.filter.page = 1;
        listTable.loadList();
    }

    function batch_export()
    {
        // 开始日期
        var start_date = Utils.trim(document.forms['searchForm'].elements['start_date'].value);
        // 终了日期
        var end_date = Utils.trim(document.forms['searchForm'].elements['end_date'].value);

        return location.href='goods_stats.php?act=export&start_date='+start_date+'&end_date='+end_date;
    }

    {/literal}
</script>
{include file="pagefooter.htm"}
{/if}